package com.aishua.fire.common;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class IdUtil {
	
	public String getAddrId() {
		return getId("Addr");
	}
	
	/**
	 * 获取随机唯一编号,共用方法
	 * @param prefix
	 * @return
	 */
	private String getId(String prefix) {
		String format = "YYYYMMddHHmmssSSS";
		
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
		String string = simpleDateFormat.format(new Date());
		Random random = new Random();
		int SuffixStr = random.nextInt(9999);
		String coreOrderNo = prefix+string+SuffixStr;
		log.info("订单编号:{}",coreOrderNo);
		return coreOrderNo;
	}
	
	
	/**
	 * 获取随机唯一编号,共用方法
	 * @param prefix
	 * @return
	 */
	public String getAllId() {
		String format = "YYMMddHHSSS";
		
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
		String string = simpleDateFormat.format(new Date());
		Random random = new Random();
		int SuffixStr = random.nextInt(99);
		String coreOrderNo = string+SuffixStr;
		log.info("订单编号:{}",coreOrderNo);
		return coreOrderNo;
	}
}
